package crafex.engine.entities;

import java.io.Serializable;

import crafex.engine.level.Level;
import crafex.engine.tools.FloatVertex2D;
import crafex.engine.tools.Tools;
import crafex.resource.items.Gun;

import android.graphics.Bitmap;
import android.graphics.Canvas;

public class Player extends Entity implements Serializable{
	
	private static final long serialVersionUID = -3125622462616725204L;
	/**the arms to be added to the sprite*/
	
	private Gun gun1;
	private int gun1ammo;
	private Gun gun2;
	private int gun2ammo;
	private Gun special;
	private int specialammo;
	private int coins;
	

	public Player(Bitmap image, int frames, int cycles){
		super(image, frames, cycles);
	}
	
	public Player(float x, float y){
		super(x, y);
	}
	
	public Player(Bitmap image, int frames, int cycles, float x, float y){
		super(image, frames, cycles, x, y);
		start();
		coordinates = new FloatVertex2D(x, y);
	}
	
	@Override
	public void start(){
		this.setMovement(new FloatVertex2D());
		this.speed = 8;
	}
	
	/**
	 * the controlls for the player
	 * @param points
	 */
	public void controls(FloatVertex2D points){
		this.setMovement(Tools.followX(getCenter(), points, speed));
		this.setLastMovement(getMovement());
	}
	
	public void setGun(){
		
	}
	
	public Gun getGun1() {
		return gun1;
	}

	public void setGun1(Gun gun) {
		this.gun1 = gun;
	}

	public Gun getGun2() {
		return gun2;
	}

	public void setGun2(Gun gun) {
		this.gun2 = gun;
	}

	public Gun getSpecial() {
		return special;
	}

	public void setSpecial(Gun weapon) {
		this.special = weapon;
	}

	public int getGun1ammo() {
		return gun1ammo;
	}

	public void setGun1ammo(int gun1ammo) {
		this.gun1ammo = gun1ammo;
	}
	
	public void addToGun1ammo(int addition){
		this.gun1ammo += addition;
	}

	public int getGun2ammo() {
		return gun2ammo;
	}

	public void setGun2ammo(int gun2ammo) {
		this.gun2ammo = gun2ammo;
	}
	
	public void addToGun2ammo(int addition){
		this.gun2ammo += addition;
	}

	public int getSpecialammo() {
		return specialammo;
	}

	public void setSpecialammo(int specialammo) {
		this.specialammo = specialammo;
	}
	
	public void addToSpecialammo(int addition){
		this.specialammo += addition;
	}

	/**
	 * use equiped gun
	 */
	public void shoot(){
		
	}
	
	public int getCoins() {
		return coins;
	}

	public void setCoins(int coins) {
		this.coins = coins;
	}
	
	public void addToCoins(int addition){
		this.coins += addition;
	}

	@Override
	public void move(){
		if(repeatedMovement != null){
			movement.addto(repeatedMovement);
		}
		coordinates.addto(movement);
		if(movement.getX() != 0 && movement.getY() != 0){
			lastMovement = new FloatVertex2D(movement.getX(), movement.getY());
		}
		Level.scroll(movement, coordinates);
		movement.reset();
	}
	
	@Override
	public void updateFirst(){
		
	}
	
	@Override
	public void updateBeforeMove(){
		
	}
	
	@Override
	public void updateLast(){
		
	}
	
	@Override
	public void drawLast(Canvas canvas){
		
	}
	
}